import { Component, ViewChild, OnInit, AfterContentInit, AfterContentChecked, AfterViewInit, AfterViewChecked } from '@angular/core';
import { NgZorroAntdModule, NzTreeNode, NzMessageService, NzModalService, NzNotificationService } from 'ng-zorro-antd';
import { PriceQuote } from './order/order.component';
import { ChildComponent } from './child/child.component';
import { transition } from '@angular/animations';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit, AfterContentInit, AfterContentChecked,
  AfterViewInit, AfterViewChecked {
  private isCollapsed: boolean = false;
  private isVisible: boolean = false;
  private percent: number = 10;
  private data: Array<NzTreeNode> = [new NzTreeNode({ title: '1', key: '1', children: [{ title: '1', key: '1' }] })];
  title = 'app';
  stock = '';
  @ViewChild("child1")
  private child1: ChildComponent;
  @ViewChild("child2")
  private child2: ChildComponent;
  private priceQuote: PriceQuote = new PriceQuote('IBM', 100);
  private googlePriceQuote: PriceQuote = new PriceQuote('Google', 100);
  constructor(public _messageService: NzMessageService, public _modalService: NzModalService,
    public _notificationService: NzNotificationService) { }
  priceQuoteHandler(quote: PriceQuote) {
    this.priceQuote = quote;
  }
  priceQuotedEventHandler(quote: PriceQuote) {
    this.googlePriceQuote = quote;
    this.stock = quote.stockCode;
  }
  ngOnInit(): void {
    this.child1.log("child1");
  }
  ngAfterContentChecked(): void {
    console.log('app content checked.');
  }
  ngAfterContentInit(): void {
    console.log('app content init.');
  }
  ngAfterViewChecked(): void {
    console.log('app view init.');
  }
  ngAfterViewInit(): void {
    console.log('app view checked.');
  }
  sendMessage($event) {
    //this._messageService.info("This is a message sent by NzMessageService.");
    //this._messageService.error("This is a message sent by NzMessageService.");
    //this._messageService.warning("This is a message sent by NzMessageService.");
    //this._messageService.success("This is a message sent by NzMessageService.");

    this._modalService.success({
      nzTitle: '提示',
      nzContent: '<p>This is a modal opened by NzModalService.</p>',
      nzOnOk: () => { this._messageService.info("ok"); },
      nzOnCancel: () => { this._messageService.info('cancel'); },
      nzClosable: true,
      nzCancelLoading: true
    });
    this.isVisible = true;
    this._notificationService.blank("通知","即日起，从6月至9月，发放高温补贴300元每月。");
  }
}
